package org.mfw.obj.mob
{
	import mx.collections.ArrayCollection;
	
	import org.mfw.interfaces.obj.list.IArtistList;
	import org.mfw.interfaces.obj.list.ISongList;
	import org.mfw.interfaces.obj.mob.IAlbum;
	import org.mfw.interfaces.obj.mob.ICover;
	import org.mfw.interfaces.obj.mob.IGenre;
	import org.mfw.obj.list.SongList;

		/**
		 * Repräsentiert eine Album 
		 * */
	public class Album extends MediaObject implements IAlbum
	{
		protected var _cover:ICover;
		protected var _genre:Genre;
		protected var _songList:SongList;
		
		public function Album(object:Object=null)
		{
			super();
			if (object) {
				this.getAlbumFromObject(object);
			}
		}
		
		protected function getAlbumFromObject(object:Object):void{
			if (object.hasOwnProperty("value")){
				this._ID=object.id;
				this._name = object.value;
				this._cover= new Cover(object.id,object.art);
			} else if ((object.hasOwnProperty("id"))&&(!object.hasOwnProperty("track"))){
				this._ID=object.id;
				this._name=object.name;
				this._cover= new Cover(object.id,object.art);
				this._genre=new Genre(object.genre);
			} else if(object[0]) {
				this._songList= new SongList();
				this._cover= new Cover(object[0].album.id,object[0].art);
				this._ID=object[0].album.id;
				this._name=object[0].album.value;
				this._songList= new SongList();
				for each (var song:Object in object as ArrayCollection) {
					this._songList.addElement(new Song(song));
				}
			 }else if(object.hasOwnProperty("track")){
					this._songList= new SongList();
					this._cover= new Cover(object.album.id,object.art);
					this._ID=object.album.id;
					this._name=object.album.value;
					this._songList= new SongList();
					this._songList.addElement(new Song(object));
				}		
		}
		
		/**
		 * Liefert die Summe der Längen aller Lieder im Album 
		 * */
		public function get length():Number
		{
			return 0;
		}
		
		/**
		 * Liefert eine Liste aller Lieder im Album 
		 * */
		public function get songList():ISongList
		{
			return this._songList;
		}
		
		/**
		 * Liefert eine Liste aller Interpreten im Album 
		 * */
		public function get artistList():IArtistList
		{
			return null;
		}
		
		/**
		 * Liefert das Cover des Albums 
		 * */
		public function get cover():ICover
		{
			return this._cover;
		}
		
		public function get genre():IGenre
		{
			return this._genre;
		}
	}
}